package com.lin.server.impl;

import com.lin.dataobject.TSRegion;
import com.lin.repository.RegionRepository;
import com.lin.server.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/9/21.
 */
@Service
public class RegionServiceImpl implements RegionService {
    @Autowired
    private RegionRepository regionRepository;
    @Override
    public List<TSRegion> findAll() {
        return regionRepository.findAll();
    }

    @Override
    public TSRegion findById(String id) {
        return regionRepository.findById(id);
    }

    @Override
    public TSRegion save(TSRegion tsRegion) {
        return regionRepository.save(tsRegion);
    }

    @Override
    public void del(TSRegion region) {
        regionRepository.delete(region);
    }

    @Override
    public Long getChildrenCount(String id) {
        return regionRepository.countByPid(id);
    }

    @Override
    public List<TSRegion> getChildren(String pid) {
        return regionRepository.findByPid(pid);
    }
}
